daysInMonthNormal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
daysInMonthLeap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
daysOfWeek = [ "mon", "tue", "wed", "thu", "fri", "sat", "sun"]

def isLeapYear(year):
    return (year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))

def daysInMonth(year):
    if isLeapYear(year):
        return daysInMonthLeap
    else:
        return daysInMonthNormal

day = 1 # jan 1901 was a tuesday
found = 0

for year in range(1901, 2001):
    for month in daysInMonth(year):
        if day == 6:
            found += 1
        
        day = (day + month) % 7
        
print found

# or a lot simpler:
#from calendar import weekday
#print sum(weekday(y, m, 1) == 6 for y in range(1901, 2001) for m in range(1, 13))
